﻿
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPage1.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Listing All Lines
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div>
    <br />
    <%= ViewData["f"] %>

    <div id='mapDiv' style="position:absolute; width:940px; height:600px; vertical-align:middle;"></div>
    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">

    <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0">
   </script>
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
   <script type="text/javascript">
       var map;
       function GetMap() {
           map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
           { credentials: "AuaJAvEEwsrj2AzmWeJY66PUmNuOx4PGEDRpPQq803auEsfkd9NlV6HhTEzZM95F",
               center: new Microsoft.Maps.Location(47.49, 19.04),
               zoom: 13
           });
       }
    </script>

    <script type="text/javascript">
        $(document).ready(function () {

            GetMap();

            $(document).ajaxError(function () {
                alert('ajaxerror');
            });
            setInterval("callWCF()", 5000);
        }
      );


        function callWCF() {

            $.post('../../InfoService.svc/InfoService/getAllVehiclePositions', null, function (data) {

                map.entities.clear();
                // alert(data.d[0].Latitude);
                for (var j = 0; j < data.d.length; j++) {
                    var loc = new Microsoft.Maps.Location(data.d[j].Latitude, data.d[j].Longitude);
                    var t = data.d[j].VehicleNumber.toString();

                    var pin = new Microsoft.Maps.Pushpin(loc, { text: t });

                    map.entities.push(pin);
                }
            })
        }
    </script>

</asp:Content>
